﻿using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.Common;
using HumanManagement.BusinessObjects;
using HumanManagement.DataAccess;

namespace HumanManagement.BusinessLogic
{
	public class DepartmentBL
	{

		#region ***** Init Methods ***** 
		DepartmentDA objDepartmentDA;
		public DepartmentBL()
		{
			objDepartmentDA = new DepartmentDA();
		}
		#endregion

		#region ***** Get Methods ***** 
		/// <summary>
		/// Get Department by id
		/// </summary>
		/// <param name="id">ID</param>
		/// <returns>Department</returns>
		public Department GetByID(int id)
		{
			return objDepartmentDA.GetByID(id);
		}

		/// <summary>
		/// Get all of Department
		/// </summary>
		/// <returns>List<<Department>></returns>
		public List<Department> GetList()
		{
			string cacheName = "lstDepartment";
			if( ServerCache.Get(cacheName) == null )
			{
				ServerCache.Insert(cacheName, objDepartmentDA.GetList(), "Department");
			}
			return (List<Department>) ServerCache.Get(cacheName);
		}

		/// <summary>
		/// Get DataSet of Department
		/// </summary>
		/// <returns>DataSet</returns>
		public DataSet GetDataSet()
		{
			string cacheName = "dsDepartment";
			if( ServerCache.Get(cacheName) == null )
			{
				ServerCache.Insert(cacheName, objDepartmentDA.GetDataSet(), "Department");
			}
			return (DataSet) ServerCache.Get(cacheName);
		}


		/// <summary>
		/// Get all of Department paged
		/// </summary>
		/// <param name="recperpage">recperpage</param>
		/// <param name="pageindex">pageindex</param>
		/// <returns>List<<Department>></returns>
		public List<Department> GetListPaged(int recperpage, int pageindex)
		{
			return objDepartmentDA.GetListPaged(recperpage, pageindex);
		}

		/// <summary>
		/// Get DataSet of Department paged
		/// </summary>
		/// <param name="recperpage">recperpage</param>
		/// <param name="pageindex">pageindex</param>
		/// <returns>DataSet</returns>
		public DataSet GetDataSetPaged(int recperpage, int pageindex)
		{
			return objDepartmentDA.GetDataSetPaged(recperpage, pageindex);
		}





		#endregion

		#region ***** Add Update Delete Methods ***** 
		/// <summary>
		/// Add a new Department within Department database table
		/// </summary>
		/// <param name="obj_department">Department</param>
		/// <returns>key of table</returns>
		public int Add(Department obj_department)
		{
			ServerCache.Remove("Department", true);
			return objDepartmentDA.Add(obj_department);
		}

		/// <summary>
		/// updates the specified Department
		/// </summary>
		/// <param name="obj_department">Department</param>
		/// <returns></returns>
		public void Update(Department obj_department)
		{
			ServerCache.Remove("Department", true);
			objDepartmentDA.Update(obj_department);
		}

		/// <summary>
		/// Delete the specified Department
		/// </summary>
		/// <param name="id">ID</param>
		/// <returns></returns>
		public void Delete(int id)
		{
			ServerCache.Remove("Department", true);
			objDepartmentDA.Delete(id);
		}
		#endregion
	}
}
